#include <stdio.h>
#include <stdlib.h>

struct Studen {
    char cName[32];
    int iNumber;
    struct Studen *pNext;
};

int iCount;

struct Studen *Create() {
    struct Studen *pHead = NULL;
    struct Studen *pEnd, *pNew;
    iCount = 0;
    pEnd = pNew = (struct Studen *) malloc(sizeof(struct Studen));
    printf("输入学生姓名，再输入学号\n");
    scanf("%s", &pNew->cName);
    scanf("%d", &pNew->iNumber);
    while (pNew->iNumber != 0) {
        iCount++;
        if (iCount == 1) {
            pNew->pNext = pHead;
            pEnd = pNew;
            pHead = pNew;
        } else {
            pNew->pNext = NULL;
            pEnd->pNext = pNew;
            pEnd = pNew;
        }
        pNew = (struct Studen *) malloc(sizeof(struct Studen));

        scanf("%s", &pNew->cName);
        scanf("%d", &pNew->iNumber);
    }
    free(pNew);
    return pHead;
}

void Print(struct Studen *pHead) {
    struct Studen *pTemp;
    int iIndex = 1;
    printf("*****本名单有%d个学生:*****\n", iCount);
    printf("\n");
    pTemp = pHead;
    while (pTemp != NULL) {
        printf("第%d个学生是：\n", iIndex);
        printf("姓名：%s\n", pTemp->cName);
        printf("学号：%d\n", pTemp->iNumber);
        printf("\n");
        pTemp = pTemp->pNext;
        iIndex++;
    }
}

int main() {
    struct Studen *pHead;
    pHead = Create();
    Print(pHead);
    return 0;
}